package com.onstar.cn.map;

import java.util.List;

import android.view.View;
import android.widget.LinearLayout;

import com.onstar.cn.map.common.DriveSegmentInfo;
import com.onstar.cn.map.common.Language;
import com.onstar.cn.map.common.LocationType;
import com.onstar.cn.map.common.PoiItemInfo;
import com.onstar.cn.map.common.PoiType;
import com.onstar.cn.map.core.OGeoPoint;
import com.onstar.cn.map.listener.ORouteHandlerListener;
import com.onstar.cn.map.listener.OSearchHandlerListener;
import com.onstar.cn.map.util.QueryOptions;

public interface MapContainer {

	/**
	 * Initialize map view with specific map level
	 * 
	 * @param mapLevel
	 *            from 0~17
	 */
	void initMapView(float mapLevel);

	/**
	 * Initialize map view with specific map level and city name.
	 * 
	 * @param mapLevel
	 * @param cityName
	 *            city name or code
	 */
	void initMapView(int mapLevel, String cityName);

	/**
	 * Set up the language that user wants to get from server.
	 * 
	 * @param language
	 *            : ZH-CN, EN-US
	 */
	void setLanguage(Language lan);

	/**
	 * Perform searching by name of key work
	 * 
	 * @param key
	 *            the key word to search
	 * @param poiType
	 *            POI type that will be searched
	 * @param cityCode
	 *            the city code
	 */
	void searchByName(String key, PoiType poiType, String cityCode, QueryOptions options);

	/**
	 * @param key
	 *            the key word to search
	 * @param poiType
	 *            POI type that will be searched
	 * @param cityCode
	 *            the city code
	 */
	void searchNearBy(String key, PoiType poiType, String cityCode, QueryOptions options);

	/**
	 * 
	 * @param routeStartPoiItemInfo
	 * @param routeEndPoiItemInfo
	 * @param hour
	 * @param minutes
	 * @throws Exception
	 */
	long caculateRoute(final PoiItemInfo routeStartPoiItemInfo, final PoiItemInfo routeEndPoiItemInfo,
					   String hour, String minutes);

	/**
	 * Calculate temp route based on start and end point.
	 * 
	 * @param routeStartPoiItemInfo
	 *            the start point info
	 * @param routeEndPoiItemInfo
	 *            the end point info
	 * @param hour
	 * @param minutes
	 * @throws Exception
	 */
	long caculateTempRoute(final PoiItemInfo routeStartPoiItemInfo, final PoiItemInfo routeEndPoiItemInfo,
						   String hour, String minutes);

	/**
	 * show route result on the map view.
	 * 
	 * @drawDefault, true will draw route shape with default route overlay of
	 *               map SDK, otherwise will draw by SOS
	 */
	void showRoute(boolean drawDefault);

	/**
	 * show route result on the map view with default route overlay of map SDK
	 */
	void showRoute();

	/**
	 * Show temp route on the map view.
	 * 
	 * @drawDefault, true will draw route shape with default route overlay of
	 *               map SDK, otherwise will draw by SOS
	 */
	void showTempRoute(boolean drawDefault);

	/**
	 * Show temp route on the map view with default paint of MAP SDK.
	 */
	void showTempRoute();

	/**
	 * Clear all layouts.
	 * 
	 * @param layout
	 */
	void clearLayout(View view);

	/**
	 * Add layout to map view.
	 * 
	 * @param layout
	 */
	void addMapViewLayout(View layout, LocationType type);

	/**
	 * Clear all overlays.
	 */
	void clearMapOverlays();

	/**
	 * Go to the specific lat and lon.
	 * 
	 * @param latit
	 * @param longit
	 */
	void goToPoint(double latit, double longit);

	/**
	 * Show location icon based on specific information and Bitmap icon.
	 * 
	 * @param poiItemInfo
	 * @param arrow
	 */
	void showLocation(final PoiItemInfo poiItemInfo, int resIcon, LocationType locationType);

	/**
	 * Show location icon based on specific information and Bitmap icon.
	 * 
	 * @param poiItemInfo
	 * @param arrow
	 */
	void showLocation(final OGeoPoint geoPoint, int resIcon);
	/**
	 * Show infowindow by current geoPoint.
	 * 
	 * @param locationType
	 */
	void showInfoWindow(LocationType locationType);

	/**
	 * Calculate the address based on latitude and longitude.
	 * 
	 * @param latitude
	 * @param longitude
	 * @return
	 * @throws Exception
	 */
	long geoCoderGps(double latitude, double longitude);

	/**
	 * 
	 * @return
	 * @throws Exception
	 */
	long nextPageResult();

	/**
	 * Go to the center of specific city
	 * 
	 * @param city
	 */
	void getCoderCity(String city);

	/**
	 * Zoom to specific lat/lon area based on center point
	 */
	void zoomToSpan();

	/**
	 * Zoom to specific zoom level and lat/lon center
	 * 
	 * @param mapLevel
	 * @param lat
	 * @param lon
	 */
	void zoomTo(int mapLevel, double lat, double lon);

	/**
	 * Add the layout of instance to the specific point of map view.
	 * 
	 * @param layout
	 * @param pt
	 *            the position of layout will be placed
	 * @param x
	 *            offset pixel of point
	 * @param y
	 *            offset pixel of point
	 */
	void addMapViewLayout(LinearLayout layout, OGeoPoint pt, int x, int y);

	/**
	 * Register rout listener to listen routing result.
	 * 
	 * @param listener
	 *            the user should implement a self listener from
	 *            <b>ORouteHandlerListener</b> to process route results.
	 */
	void registerMapRouteListener(ORouteHandlerListener listener);

	/**
	 * Show location based on location type.
	 * 
	 * @param locationType
	 *            an enum of location type: MYSELF, VEHICLE, POI
	 * @param poiItemInfo
	 */
	void showLocation(LocationType locationType, PoiItemInfo poiItemInfo);
	/**
	 * Show location based on location type.
	 * 
	 * @param locationType
	 *            an enum of location type: MYSELF, VEHICLE, POI
	 * @param poiItemInfo
	 */
	void showLocation(LocationType locationType, PoiItemInfo poiItemInfo,boolean isShowInfoWindow);

	/**
	 * Get current query options
	 */
	QueryOptions getQueryOptions();

	/**
	 * Set the queryOptions to search engine.
	 * 
	 * @param queryOptions
	 */
	void setQueryOptions(QueryOptions queryOptions);

	/**
	 * Register listener to get search results
	 * 
	 * @param listener
	 *            , the consumer should be inherited from listener of
	 *            OSearchHandlerListener
	 */
	void registerMapSearchListener(OSearchHandlerListener listener);
	
	/**
	 * Configure the traffic layer, enable or not.
	 * 
	 * @param enable
	 *            true to display traffic layer, otherwise false.
	 */
	void setTraffic(boolean enable);

	void initMapView(int mapLevel, OGeoPoint center);

	/**
	 * convert pixels to latitude/longitude
	 * 
	 * @param x
	 *            pixel value
	 * @param y
	 *            pixel value
	 * @return an object of OGeoPoint
	 */
	OGeoPoint fromPixels(int x, int y);

	/**
	 * Clear all overlays of location and location information from map view.
	 */
	void clearLocations();

	/**
	 * Clear the location info of start and end point for temp route.
	 */
	void clearTempRoutePoints();

	/**
	 * Remove specific view from map view
	 */
	void removeMapView(View view);

	/**
	 * Get the results of routing
	 * 
	 * @return the list of DriveSegmentInfo
	 */
	List<DriveSegmentInfo> getDriveSegmentResultList();

	/**
	 * Get the distance of routing
	 * 
	 * @return
	 */
	String getRouteDistance();

	/**
	 * Get the hours or minutes of routing
	 * 
	 * @return
	 */
	String getRouteTime();

	void clearRouteOverlay();

	/**
	 * Get start point of route
	 * 
	 * @return OGeoPoint
	 */
	OGeoPoint getRouteStart();

	/**
	 * Get end point of route
	 * 
	 * @return OGeoPoint
	 */
	OGeoPoint getRouteEnd();

	/**
	 * Add start or end point icon to map view for route shape.
	 * 
	 * @param layout
	 * @param pt
	 * @param x
	 * @param y
	 * @param isStart
	 *            , true that means the current layout is start point, otherwise
	 *            end point
	 */
	void addMapRouteLayout(LinearLayout layout, OGeoPoint pt, int x, int y, boolean isStart);

	/**
	 * Drive mode for routing calculation.
	 * 
	 * @param driveMode
	 *            , there are there
	 *            modes:DrivingNoFastRoad,DrivingLeastDist,DrivingSaveMoney
	 */
	void setDriveMode(int driveMode);

	/**
	 * Reset the start and end points based on location type
	 * 
	 * @param locationType
	 */
	void resetRoutePoints(LocationType locationType);

	/**
	 * change city based city code/name and map level
	 * 
	 * @param city
	 * @param mapLevel
	 */
	void getCoderCity(String city, int mapLevel);

	void setRouteIcons(int startIcon, int endIcon, int wayIcon);

	void enableCompass(boolean enable);

	void setZoomControlsEnabled(boolean enable);
}
